<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <if condition="$Request.param.status == 1">
             <li class="active"><a href="">新建行政班管理</a></li>
        <else/>
             <li class="active"><a href="">新建主题班管理</a></li>
        </if>
       
    </ul>
    <form class="well form-inline margin-top-20" > 
       
      
        <input type="text" class="form-control class_name" name="class_name" style="width: 200px;"
               value="" placeholder="请输入班级名称">
        <input type="button" class="btn btn-primary" value="创建" onclick="play()"/>
    </form>
    <form method="post" class="js-ajax-form margin-top-20" action="">
       
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                             data-checklist="js-check-x" value="0"></label></th>
               
                <th>姓名</th>
            </tr>
            </thead>
            <tbody class="tbody">
                <foreach name="data" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                    </td>
                    <td>{$vo.realName}</td>
                </tr>
                </foreach>
            </tbody>
           
        </table>
         <ul class="pagination">{$page|default=''}</ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    function play() {
        var class_name = $('.class_name').val();
        
        if(class_name == ''){
            alert('请输入班级名称');return false;
        }

        var vals = [];
         $('input:checkbox').each(function (index, item) {  
            var value = $(this).val();
            if(value != 0){
                vals.push(value);
            }
         });
         vals = vals.join('-');
         var status = {$Request.param.status};
        $.post("{:cmf_url('toAdd')}",{class_name:class_name,vals:vals,status:{$status}},function(data){
            alert('成功');
             if(data.code==1){  
                if(status == 1){
                    setTimeout(
                        "window.location.href = 'http://'+window.location.host+'/teacher/Relation/index_1'",
                    1000 )
                }else{
                    setTimeout(
                        "window.location.href = 'http://'+window.location.host+'/teacher/Relation/index_2'",
                    1000 )
                }
                
            }
        });
    }

</script>
</body>
</html>